/**
* 左边菜单
*/
<template>
  <!-- default-active="2" -->
  <el-menu :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened
    class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{ menu.menuname }}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{ chmenu.menuname }}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
  export default {
    name: "leftnav",
    data() {
      return {
        collapsed: false,
        user: 'atlas',
        allmenu: [],
      };
    },
    // 创建完毕状态(里面是操作)
    created() {
      // 获取图形验证码
      let res = {
        success: true,
        msg: "success",
        data: [
          {
            menuid: 40,
            menuname: "项目管理",
            hasThird: null,
            url: null,
            menus: [
              {
                menuid: 41,
                menuname: "项目模板",
                hasThird: "N",
                url: "/tmpls",
                menus: null,
              },
            ],
          },
          {
            menuid: 10,
            menuname: "数据管理",
            hasThird: null,
            url: null,
            menus: null,
            menus: [
              {
                menuid: 11,
                menuname: "影像数据",
                hasThird: "N",
                url: "/rasters",
                menus: null,
              },
              {
                menuid: 12,
                menuname: "地形数据",
                hasThird: "N",
                url: "/terrains",
                menus: null,
              },
            ],
          },
          {
            menuid: 20,
            // icon: "li-icon-dingdanguanli",
            menuname: "服务管理",
            // hasThird: null,
            url: null,
            menus: null,
            menus: [
              {
                menuid: 21,
                menuname: "底图服务",
                hasThird: "N",
                url: "/services",
                menus: null,
              },
            ],
          },
          {
            menuid: 30,
            // icon: "li-icon-xitongguanli",
            menuname: "算法管理",
            hasThird: null,
            url: "/algorithms",
            menus: [
              {
                menuid: 31,
                menuname: "算法列表",
                hasThird: "N",
                url: "/algorithms",
                menus: null,
              },
            ],
          },
          {
            menuid: 50,
            // icon: "icon-provider-manage",
            menuname: "报告管理",
            hasThird: null,
            url: null,
            menus: [
              {
                menuid: 51,
                menuname: "实验报告",
                hasThird: "N",
                url: "/reports",
                menus: null,
              },
            ],
          },
          {
            menuid: 60,
            icon: "icon-cus-manage",
            menuname: "用户管理",
            hasThird: null,
            url: null,
            menus: [
              {
                menuid: 61,
                menuname: "系统用户",
                hasThird: "N",
                url: "/users",
                menus: null,
              },
            ],
          },
        ],
        data2: [
          {
            menuid: 50,
            // icon: "icon-provider-manage",
            menuname: "报告管理",
            hasThird: null,
            url: null,
            menus: [
              {
                menuid: 51,
                menuname: "实验报告",
                hasThird: "N",
                url: "/reports",
                menus: null,
              },
            ],
          }
        ]
      };
      this.user = localStorage.getItem("user");
      if (this.user == 'atlas') {
        this.allmenu = res.data;
      } else {
        this.allmenu = res.data2;
      }
    },
  };
</script>
<style>
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 240px;
    min-height: 400px;
    height: 100%;
  }

  .el-menu-vertical-demo:not(.el-menu--collapse) {
    border: none;
    text-align: left;
  }

  .el-menu-item-group__title {
    padding: 0px;
  }

  .el-menu-bg {
    background-color: #1f2d3d !important;
  }

  .el-menu {
    border: none;
  }

  .logobox {
    height: 40px;
    line-height: 40px;
    color: #9d9d9d;
    font-size: 20px;
    text-align: center;
    padding: 20px 0px;
  }

  .logoimg {
    height: 40px;
  }
</style>